/////////////////////////////////////////////////////////////////////////////////////
// Header Protection
#ifndef _CAMERA_H_
#define _CAMERA_H_

/////////////////////////////////////////////////////////////////////////////////////
// This class provides a viewpoint from which to render.
class CCamera
{
public:
	matrix_t m_matTransform;
	matrix_t m_matProjection;

	matrix_t GetTransform()  const { return m_matTransform; }
	matrix_t GetProjection() const { return m_matProjection; }
	
	// TODO: it will obviously be a problem to have to overload new in every 
	//     dynamically allocated class which uses a vector or matrix, I will have to 
	//     do something about this for sure... 
	// TEMP: overloading new in every dynamically allocated class that uses __m128
	// LATER: overload new globally to take in an alignment
	// AWESOME: memory manager automatically knows to align it
	void *operator new( uint_t _uiBytes )
	{
		// allocate memory with some extra
		byte_t *pUnaligned = (byte_t *)malloc( _uiBytes + 16 );

		// move the pointer over at least one and align it
		byte_t *pAligned = pUnaligned + (16 - uint_t(pUnaligned) % 16);

		// add the offset into the previous byte
		pAligned[-1] = byte_t(pAligned - pUnaligned);

		// return the aligned memory
		return pAligned;
	}

	void operator delete(void *pAligned)
	{
		// find the amount this pointer was offset for alignment
		byte_t uiOffset = ((byte_t *)pAligned)[-1];

		// move the pointer
		byte_t *pUnaligned = (byte_t *)pAligned - uiOffset;

		// free the memory
		free(pUnaligned);
	}

	CCamera();

	void SetPerspective( float_t _fFOV, float_t _fAspect, 
		float_t _fNear, float_t _fFar );

	void Translate( float_t _fX, float_t _fY, float_t _fZ );

	void RotateViewAroundOrigin( float_t _fX, float_t _fY );
};

/////////////////////////////////////////////////////////////////////////////////////
// Header Protection
#endif // _CAMERA_H_
